/**
 * 提现功能混入
 */
import { getStatusText, getStatusColor, validateWithdrawAmount, formatAmount, formatTime } from '@/common/lib/util/withdrawUtil.js'

export default {
    data() {
        return {
            withdrawLoading: false
        }
    },
    
    methods: {
        // 格式化提现状态
        formatWithdrawStatus(status) {
            return getStatusText(status);
        },
        
        // 获取状态颜色
        getWithdrawStatusColor(status) {
            return getStatusColor(status);
        },
        
        // 验证提现金额
        validateWithdrawAmount(amount, availableAmount) {
            return validateWithdrawAmount(amount, availableAmount);
        },
        
        // 格式化金额
        formatWithdrawAmount(amount) {
            return formatAmount(amount);
        },
        
        // 格式化时间
        formatWithdrawTime(timeStr) {
            return formatTime(timeStr);
        },
        
        // 显示提现成功提示
        showWithdrawSuccess(message = '操作成功') {
            uni.showToast({
                title: message,
                icon: 'success',
                duration: 2000
            });
        },
        
        // 显示提现错误提示
        showWithdrawError(message = '操作失败') {
            uni.showToast({
                title: message,
                icon: 'none',
                duration: 2000
            });
        },
        
        // 确认对话框
        confirmWithdrawAction(title, content) {
            return new Promise((resolve, reject) => {
                uni.showModal({
                    title,
                    content,
                    success: (res) => {
                        if (res.confirm) {
                            resolve(true);
                        } else {
                            resolve(false);
                        }
                    },
                    fail: reject
                });
            });
        }
    }
}